/**
 * Created by Administrator on 2015/12/25.
 */
(function (a) {
    var d = "PriceBox", b = "1.9", c = a.__;
    c.register("fn-pricebox", b, ["fn-base", "fn-smartbox"], function () {
        if (!c.isSet("__.widget." + d)) {
            c.set("__.widget." + d);
            c.widget[d] = (function () {
                var q = c.Dom, p = c.Event, m = c.Lang, l = c.log, n = c.widget, e = c.Cookie, i = c.config.win, o = {
                    txt: {
                        hide: "\u9690\u85cf\u62a5\u4ef7\u680f",
                        show: "\u5b8c\u6574\u663e\u793a\u62a5\u4ef7\u680f",
                        refresh: "\u66f4\u65b0\u5373\u65f6\u62a5\u4ef7"
                    },
                    cls: {
                        ctn: "du-pb-ctn",
                        sb: "du-pb-smartbox",
                        screen: "du-pb-screen",
                        refresh: "du-pb-refresh",
                        notice: "du-pb-notice",
                        add: "du-pb-add",
                        toggle: "du-pb-toggle",
                        toggleOn: "du-pb-toggle-on",
                        contents: "du-pb-contents",
                        ff: "du-pb-ff"
                    },
                    status: {},
                    defInstCfg: {
                        typeWait: 30,
                        showType: true,
                        defaultType: "ALL",
                        showPLink: true,
                        defaultCode: "sh000001",
                        defaultSmallType: "zssh",
                        zindex: 1,
                        addStock: false,
                        cronObj: null
                    },
                    backImgSrc: "http://mat1.gtimg.com/finance/js/stock/widget/pricebox.gif",
                    iNoticeTimer: 10000
                }, h = function (s, r, t) {
                    s.style.backgroundPosition = r + "px " + t + "px"
                }, g = false, k = c.config.ua.ie == 6, f = c.Table.MAP_STOCKTYPE, j = function (r, s) {
                };
                return __.Class.extend({
                    version: b, cache: {}, _initCfg: function (s) {
                        s = s || {};
                        this._config = m.clone(o.defInstCfg);
                        var r = this._config;
                        m.e(s, function (u, t) {
                            r[t] = u
                        }, true)
                    }, _createStyleSheet: function () {
                        if (!g) {
                            var r = o.cls;
                            q.addStyle("." + r.screen + " a{color:#1045B9;text-decoration:none;}." + r.screen + " a:hover {color:#c00;text-decoration:underline;}." + r.ff + "{font-family:Tahoma;}");
                            g = true
                        }
                    }, _createEls: function () {
                        if (q.f(this.id)) {
                            throw new Error('container id "' + this.id + '" already in use.')
                        }
                        var r = o.cls, t = "background:transparent url(" + o.backImgSrc + ") no-repeat ", s = {
                            id: this.id,
                            css: "position:fixed;bottom:0px;left:0px;width:100%;font-size:12px;visibility:hidden;z-index:" + this._config.zindex,
                            child: {
                                css: "width:960px;height:30px;line-height:28px;border-bottom:0;margin:auto;",
                                cls: r.ctn,
                                child: {
                                    css: "border:1px solid #b5b5b5;float:right;background:transparent url(" + o.backImgSrc + ") repeat-x 0 0px;overflow:hidden;height:28px;",
                                    child: [{
                                        css: "float:right;width:35px;",
                                        child: {
                                            css: "width:35px;height:28px;" + t + "0 -111px;cursor:pointer;",
                                            cls: r.toggle,
                                            title: o.txt.hide
                                        }
                                    }, {
                                        css: "float:right",
                                        cls: r.contents,
                                        child: [{
                                            css: "float:left;width:137px;padding-top:4px;",
                                            text: "smartbox",
                                            cls: r.sb,
                                            id: this.smartBoxId
                                        }, {
                                            css: "float:left;width:433px;padding-top:4px;",
                                            child: {
                                                css: "width:431px;height:18px;border:1px solid #c9c9c9;background:#fff;line-height:18px;padding:0 5px;overflow:hidden;",
                                                cls: [r.screen, r.ff]
                                            }
                                        }, {
                                            css: "float:left;width:23px;padding:4px 0 0;",
                                            child: {
                                                css: "width:23px;height:21px;" + t + "0 -71px;cursor:pointer;",
                                                cls: r.refresh,
                                                title: o.txt.refresh
                                            }
                                        }, {
                                            css: "float:left;width:" + (k ? 136 : 146) + "px;padding:0 10px;",
                                            text: "notice",
                                            cls: [r.notice, r.ff]
                                        }, {
                                            css: "float:left;width:74px;padding:4px 5px 0 0;",
                                            child: {
                                                css: "width:74px;height:20px;" + t + "0 -91px;cursor:pointer;",
                                                cls: r.add
                                            }
                                        }]
                                    }, {
                                        css: "float:right;width:58px;text-align:left;font-weight:bold;*padding-top:1px;",
                                        text: "\u5373\u65f6\u62a5\u4ef7"
                                    }, {
                                        css: "float:right;width:21px;padding:7px 0 0 6px;",
                                        child: {css: "width:17px;height:13px;" + t + "0 -28px;"}
                                    }]
                                }
                            }
                        };
                        q.addEl(s, __.config.doc.body)
                    }, _initEls: function () {
                        var r = o.cls, t = "#" + this.id + " .", s = {};
                        m.e(r, function (v, u) {
                            s[u] = q.f(t + v)
                        }, true);
                        this.els = s;
                        this.container = q.f(this.id);
                        if (k) {
                            this._fixPositionForSuckerBrowser()
                        }
                    }, _fixPositionForSuckerBrowser: function () {
                        var r = this.container.style;
                        r.position = "absolute";
                        r.top = q.getWindowXY()[1] + q.getScrollXY()[1] - 30 + "px"
                    }, _initEventsMap: function () {
                        var x = {}, v = this, r = o.cls, t = this.els, w = t.refresh, u = t.toggle, s = t.add;
                        x[r.refresh] = function () {
                            h(w, -23, -71);
                            v._fnMouseOut = function () {
                                h(w, 0, -71)
                            }
                        };
                        x[r.toggle] = function () {
                            h(u, -35, v.toggleBackHeight);
                            v._fnMouseOut = function () {
                                h(u, 0, v.toggleBackHeight)
                            }
                        };
                        x[r.add] = function () {
                            h(s, 0, -167);
                            v._fnMouseOut = function () {
                                h(s, 0, -91)
                            }
                        };
                        this._oOnMouseOver = x;
                        x = {};
                        x[r.toggle] = function () {
                            v.toggle()
                        };
                        x[r.refresh] = function () {
                            v.refresh()
                        };
                        x[r.add] = function () {
                            if (v._config.addStock) {
                                v._config.addStock(v.currentCode, v.currentType)
                            } else {
                                j(v.currentCode, v.currentType)
                            }
                        };
                        this._oOnClick = x
                    }, _initTimers: function () {
                    }, _updateTime: function (s, r) {
                        var u, t;
                        if (r == "200") {
                            s = new Date(s);
                            t = function (v) {
                                return (v >= 10 ? "" : "0") + v
                            };
                            u = t(s.getMonth() + 1) + "-" + t(s.getDate()) + " " + t(s.getHours()) + ":" + t(s.getMinutes())
                        } else {
                            s = s.replace(m.getReg("[- /:]", "g"), "");
                            u = s.substr(4, 2) + "-" + s.substr(6, 2) + " " + s.substr(8, 2) + ":" + s.substr(10, 2)
                        }
                        this.els.notice.innerHTML = '<span style="font-size:11px;">' + u + "</span>"
                    }, _clearLastMouseOver: function () {
                        if (this._fnMouseOut) {
                            this._fnMouseOut();
                            this._fnMouseOut = null
                        }
                    }, _addEvents: function () {
                        var u = p.bind, s = this.els, r = this.container;
                        p.on(s.ctn, "mouseover", u(this._hlMouseOver, this));
                        p.on(s.ctn, "click", u(this._hlClick, this));
                        p.on(s.ctn, "mouseout", u(this._hlMouseOut, this));
                        if (k) {
                            var t = function () {
                                var v = q.getWindowXY()[1] + q.getScrollXY()[1] - 30;
                                r.style.top = v + "px"
                            };
                            p.on([i], "resize", t);
                            p.on([i], "scroll", t)
                        }
                    }, _fillScreen: function (t, w) {
                        t = t.split("~");
                        var s, v = c.Table.processors, r = this.oSmartBox, u = function (x) {
                            return '<span style="font-size:11px;">' + x + "</span>"
                        };
                        if (t.length > 10) {
                            s = t[2];
                            this._updateTime(t[30], t[0]);
                            this.currentType = f[t[0]];
                            this.els.screen.innerHTML = [v.GET_TITLE(t[2], t[0], t[1], false, "_blank"), u(v.GET_COLOR(t[3], t[32])), u(v.L_PERCENT(t)), "\u6700\u9ad8:" + u(t[33]), "\u6700\u4f4e:" + u(t[34]), "\u6210\u4ea4\u91cf:" + u((t[36] / 10000).toFixed(0)) + "\u4e07\u80a1"].join(" &nbsp;")
                        } else {
                            s = t[0];
                            this._updateTime(t[4], 0);
                            this.currentType = "jj";
                            this.els.screen.innerHTML = [v.GET_TITLE(t[0], "0", t[1]), u(v.GET_COLOR(t[2], t[3])), u(v.GET_PERCENT(t[3])), "\u51c0\u503c:" + u(t[5]), "\u7d2f\u8ba1\u51c0\u503c:" + u(t[6])].join(" &nbsp;")
                        }
                        if (!w) {
                            r.queryIpt.value = s.split(".")[0];
                            r.queryIpt.select();
                            r.listQT = (r.queryIpt.value + "~").toLowerCase() + r.typeIpt.value
                        }
                    }, _loadInitData: function () {
                        var r = this, s = this._config;
                        if (s.cronObj === null) {
                            setTimeout(function () {
                                r.refresh(s.defaultCode, s.defaultSmallType, true)
                            }, 300)
                        } else {
                            s.cronObj.subscribe({
                                judge: 1, runOnce: true, onOk: function () {
                                    var t = i["v_" + s.defaultCode];
                                    if (t) {
                                        r._fillScreen(t, true);
                                        r.currentCode = s.defaultCode;
                                        r.currentSmallType = s.defaultSmallType
                                    }
                                }
                            })
                        }
                    }, _loadSmartbox: function () {
                        var r = this, s, t = function () {
                            r.els.sb.innerHTML = "";
                            var y = new __.widget.SmartBox(r.smartBoxId, {
                                defaultType: "ALL",
                                showPLink: false,
                                showTitle: false,
                                showType: false,
                                directionUp: true,
                                autoSelect: true,
                                zindex: r._config.zindex + 1,
                                onclick: function (z) {
                                    if (z[2] && z[2] in f) {
                                        r.refresh(f[z[2]] + z[1], z[3], false)
                                    }
                                },
                                onsubmit2: function (G, F, z) {
                                    var E = z, C, A, D = E._config.onclick, B = function () {
                                        if (!E.zeroList) {
                                            A = E.resultList.childNodes;
                                            C = E._hasMatchRow() || A[A.length - 1].id.split("~");
                                            D(C)
                                        } else {
                                            r.error(z.queryIpt.value)
                                        }
                                    };
                                    p.stopEvent(G);
                                    if (F) {
                                        D(F.id.split("~"))
                                    } else {
                                        if (!E.isQueryChanged()) {
                                            r.refresh()
                                        } else {
                                            l("b4show redefined");
                                            E.b4Show = function () {
                                                B();
                                                E.b4Show = false;
                                                return false
                                            }
                                        }
                                    }
                                }
                            });
                            var w = y.queryIpt.style, v = y.subIpt.style, u = y.show, x = false;
                            y.subIpt.parentNode.style.marginRight = "0";
                            y.subIpt.parentNode.style.padding = "0";
                            w.width = "83px";
                            w.paddingLeft = "1px";
                            v.width = "36px";
                            v.height = "20px";
                            v.background = "transparent url(" + o.backImgSrc + ") no-repeat 0 -41px";
                            y.subIpt.value = " ";
                            if (c.config.ua.ie) {
                                w.padding = "0 0 3px 1px";
                                w.height = "14px"
                            }
                            if (!k) {
                                y.show = function (z) {
                                    var A = this.resultList.parentNode;
                                    A.style.position = "fixed";
                                    A.style.top = (q.getWindowXY()[1] - A.offsetHeight - 29) + "px";
                                    if (x != parseInt(A.style.left)) {
                                        x = parseInt(A.style.left) - 50;
                                        A.style.left = x + "px"
                                    }
                                    u.call(y, z, false)
                                }
                            } else {
                                y.show = function (z) {
                                    var A = this.resultList.parentNode;
                                    A.style.top = (q.getScrollXY()[1] + q.getWindowXY()[1] - A.offsetHeight - 29) + "px";
                                    if (x != parseInt(A.style.left)) {
                                        x = parseInt(A.style.left) - 50;
                                        A.style.left = x + "px"
                                    }
                                    u.call(y, z, false)
                                }
                            }
                            r.oSmartBox = y;
                            r.container.style.visibility = "visible"
                        };
                        if (__.isSet("__.widget.SmartBox")) {
                            t()
                        } else {
                            c.load("fn-smartbox", t)
                        }
                    }, _hlClick: function (t) {
                        t = t || i.event;
                        var r = t.target || t.srcElement, s = r.className;
                        if (s && s in this._oOnClick) {
                            this._oOnClick[s]()
                        }
                    }, _hlMouseOver: function (t) {
                        t = t || i.event;
                        var r = t.target || t.srcElement, s = r.className;
                        if (s && s in this._oOnMouseOver) {
                            this._clearLastMouseOver();
                            this._oOnMouseOver[s]()
                        } else {
                            this._clearLastMouseOver()
                        }
                    }, _hlMouseOut: function (t) {
                        t = t || i.event;
                        var r = t.target || t.srcElement, s = r.className;
                        this._clearLastMouseOver()
                    }, toggle: function (r) {
                        r = m.isBoolean(r) ? r : !this.toggleExpanded;
                        var t = this.els, s = t.contents;
                        if (r === !this.toggleExpanded) {
                            if (r) {
                                s.style.display = "block";
                                s.parentNode.style.width = "auto";
                                this.toggleBackHeight = -111;
                                t.toggle.title = o.txt.hide
                            } else {
                                s.style.display = "none";
                                s.parentNode.style.width = k ? "123px" : "120px";
                                this.toggleBackHeight = -139;
                                t.toggle.title = o.txt.show
                            }
                            this.toggleExpanded = r;
                            h(t.toggle, -35, this.toggleBackHeight)
                        }
                    }, refresh: function (t, r, w) {
                        var v = t || this.currentCode, u = this, s = v.split(".")[0];
                        r = r || this.currentSmallType;
                        this.els.screen.innerHTML = "\u8bfb\u53d6\u4e2d...";
                        if (m.startWith(s, "hk")) {
                            s = "r_" + s
                        }
                        c.Table.load(s, function () {
                            var x = i["v_" + s];
                            if (x) {
                                u._fillScreen(x, w);
                                u.currentCode = v;
                                u.currentSmallType = r;
                                u.oSmartBox && u.oSmartBox.hide()
                            } else {
                                u.error(v)
                            }
                        })
                    }, error: function (s) {
                        var r = this.els.screen;
                        if (s) {
                            s = '\u6ca1\u6709\u627e\u5230<span style="color:#f00;">' + s + "</span>\u7684\u62a5\u4ef7\u6d88\u606f\uff0c\u8bf7\u60a8\u68c0\u67e5\u62fc\u5199\u540e\u91cd\u65b0\u8f93\u5165\u3002"
                        } else {
                            s = "\u8bf7\u8f93\u5165\u9700\u8981\u67e5\u8be2\u7684\u80a1\u7968\u4ee3\u7801\u3002"
                        }
                        r.innerHTML = '<div style="background:transparent url(' + o.backImgSrc + ') no-repeat 0 -61px;height:10px;width:10px;float:left;margin:4px 3px 0 0;font-size:0;line-height:0;"></div>' + s;
                        r.style.backgroundColor = "#fffbde"
                    }, init: function (s, r) {
                        this.id = s;
                        this.smartBoxId = s + "_" + o.cls.sb;
                        this.toggleBackHeight = -111;
                        this.toggleExpanded = true;
                        this._createStyleSheet();
                        this._initCfg(r);
                        this._createEls();
                        this._initEls();
                        this._initEventsMap();
                        this._addEvents();
                        this._loadSmartbox();
                        this._loadInitData()
                    }
                })
            }())
        }
    })
}(this));
/*  |xGv00|0717d181df87f89530ca7a3186acb3ee */